﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using System;
using System.Runtime.InteropServices;
using Beyond;
using Beyond.Ant;

public class UnityHelper {
    /// /////////////////////////////////////////////////////
    /// 在托管dll使用前调用可引导托管dll导入非托管dll （editor、win32有效，android无效）
//#if UNITY_IPHONE
//    [DllImport ("__Internal")]
//#else
//    [DllImport("beyond")]
//#endif
//    private static extern IntPtr beyondVersion();
//    public static void ImportNativeDll() {
//        //string ver = Marshal.PtrToStringAnsi(beyondVersion());
//        //Debug.Log("@" + ver);
//    }
    /// /////////////////////////////////////////////////////

    public static void InitEnvironment() {
        Global.initialize(new Beyond.CLBridgeImpl());
        Debug.Log("@" + Global.beyondVersion());
        InitEnvironment(false);
    }

    public static void InitEnvironment(bool runtime) {
#if UNITY_2018_4
        if (runtime) {
            Debug.Log("-: UNITY_2018_4");
        } else {
            BEUnity.version = BEUnity.Version.v2018_4_15;
        }
#elif UNITY_2018_2
        if (runtime) {
            Debug.Log("-: UNITY_2018_2");
        } else {
            BEUnity.version = BEUnity.Version.v2018_2_14;
        }
#elif UNITY_5_6
        if (runtime) {
            Debug.Log("-: UNITY_5_6");
        } else {
            BEUnity.version = BEUnity.Version.v5_6_4;
        }
#else
        BEUnity.version = BEUnity.Version.unknow;
#endif

#if UNITY_EDITOR
        if (runtime) {
            Debug.Log(" -: UNITY_EDITOR");
        } else {
            BEUnity.isEditor = true;
        }
#endif

#if UNITY_ANDROID
        BEUnity.platform = BEUnity.Platform.Android;
#elif UNITY_IPHONE
        BEUnity.platform = BEUnity.Platform.Ios;
#elif UNITY_STANDALONE_WIN
        BEUnity.platform = BEUnity.Platform.Windows;
#elif UNITY_STANDALONE_OSX
        BEUnity.platform = BEUnity.Platform.OsX;
#endif

        if (runtime) {
            BEUnity.Init();
        }
        Debug.Log(BEUnity.summary);
    }

}